# -*- coding: utf-8 -*-
print 'koro.modules.commerciale'
from koro.core.model import ModuleInfo
from koro.modules.commerciale import context,ui,model,__version__
from koro.modules.commerciale.ui import page,panel


info=ModuleInfo(dependency=None,
                description='Modulo per la gestione dei rapporti commerciali. Listini, Aliquote Iva, Spese, Modalità di Pagamento ecc. ',
                version=__version__.VERSION_STRING,
                weight=200)

def id_map():    
    return {ui.ID_CODIVA_PAGE:context.CodiciIvaContext,
            ui.ID_LISTINI_PAGE:context.ListiniContext}

def context_map():    
    return {context.ListiniContext:(page.ListiniPage,(),{}),
            context.CodiciIvaContext:(page.CodiciIvaPage,(),{})}

def name_map():    
    return {'LISTINI':context.ListiniContext,
            'ALIQUOTE_IVA':context.CodiciIvaContext,
            }

def or_mapping(mapper,relation,metadata,Table):    
    mapper(model.Listino,Table('listini',metadata,autoload=True))    
    mapper(model.Iva,Table('aliquote_iva',metadata,autoload=True))
    mapper(model.Spese,Table('spese',metadata,autoload=True),
           properties={'iva':relation(model.Iva,uselist=False),
                       })
        

def menu(menubar):
    ui.do_menu(menubar)

def option_view():
    return panel.CommercialeOptionPanel